package com.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.xiaochun.hxhj.R;

import java.util.List;


public class TestTableAdapter extends BaseAdapter {


    private Context context;
    private LayoutInflater mInflater;
    List<String> mData;
    public int checkedPosition = 0;
    public String type = "0";
    public boolean isshow = true;
    public boolean isCheck = false;
    public String checkposs = "";
    public boolean istrue = true;
    public int width = 90;

    public TestTableAdapter(Context context){
        this.mInflater = LayoutInflater.from(context);
    }

    public TestTableAdapter(Context context, List<String> mData){
        this.context=context;
        this.mInflater = LayoutInflater.from(context);
        this.mData=mData;


    }
    public void setData(List<String> mData,String type,int width){
        this.mData=mData;
        this.type = type;
        this.width = width;
        checkedPosition = 0;
        isshow = true;
        isCheck = false;
        checkposs = "";
        istrue = true;
        notifyDataSetChanged();
    }
    public void setGone(){
        isshow = false;
        notifyDataSetChanged();
    }
    public void setCheckedItem(int position,String checkposs,boolean istrue){
        this.checkedPosition=position;
        this.checkposs=checkposs;
        this.istrue=istrue;
        isshow = false;
        isCheck = true;
        notifyDataSetChanged();
    }
    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public Object getItem(int arg0) {
        return null;
    }

    @Override
    public long getItemId(int arg0) {
        return 0;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            holder=new ViewHolder();
            convertView = mInflater.inflate(R.layout.item_nine_table, null);
            holder.img_nine_table = (ImageView) convertView.findViewById(R.id.img_nine_table);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder)convertView.getTag();
        }

//        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) holder.img_nine_table.getLayoutParams();
//        layoutParams.height = width;
//        layoutParams.width = width;
//        holder.img_nine_table.setLayoutParams(layoutParams);

        holder.img_nine_table.setImageResource(R.mipmap.icon_heart_green);

        return convertView;
    }
    public static class ViewHolder{
        ImageView img_nine_table ;
    }



}